package org.com.lcuiot.security;

import java.nio.ByteBuffer;
import java.util.Base64;

/**
 * Base64
 *
 * @author Kweny
 * @since 2020-04-25 16:12
 */
public class Base64Crypto {

    public String encodeToString(byte[] src) {
        return Base64.getEncoder().encodeToString(src);
    }

    public byte[] encode(byte[] src) {
        return Base64.getEncoder().encode(src);
    }

    public int encode(byte[] src, byte[] dst) {
        return Base64.getEncoder().encode(src, dst);
    }

    public ByteBuffer encode(ByteBuffer buffer) {
        return Base64.getEncoder().encode(buffer);
    }

    public byte[] decode(byte[] src) {
        return Base64.getDecoder().decode(src);
    }

    public byte[] decode(String src) {
        return Base64.getDecoder().decode(src);
    }

    public int decode(byte[] src, byte[] dst) {
        return Base64.getDecoder().decode(src, dst);
    }

    public ByteBuffer decode(ByteBuffer buffer) {
        return Base64.getDecoder().decode(buffer);
    }

}
